package com.billdowney.service.impl.system.log;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.billdowney.dao.system.log.SystemLogDao;
import com.billdowney.entity.system.log.SystemLog;
import com.billdowney.entity.user.UserLoginInfo;
import com.billdowney.service.impl.base.BaseServiceImpl;
import com.billdowney.service.interfaces.system.log.SystemLogService;
import com.billdowney.util.CommonUtil;
import com.billdowney.util.log.SystemLogHandleType;

/**
 * 系统日志接口实现
 * 
 * @author 超级小富翁 - BillDowney
 * @date 2019年4月29日 上午11:32:56
 */
@Service
public class SystemLogServiceImpl extends BaseServiceImpl<SystemLogDao, SystemLog, String> implements SystemLogService {

	@Resource(type = SystemLogDao.class)
	@Override
	public void setDao(SystemLogDao dao) {
		super.dao = dao;
	}

	@Override
	public SystemLog save(String logDesc, SystemLogHandleType handleType, Class<?> aboutClass) {
		return this.save(logDesc, handleType, aboutClass, null, super.getUserLoginInfo());
	}

	@Override
	public SystemLog save(String logDesc, SystemLogHandleType handleType, Class<?> aboutClass, String note) {
		return this.save(logDesc, handleType, aboutClass, note, super.getUserLoginInfo());
	}

	@Override
	public SystemLog save(String logDesc, SystemLogHandleType handleType, Class<?> aboutClass, String note,
			UserLoginInfo userLoginInfo) {
		SystemLog log = new SystemLog();
		log.setLogDesc(logDesc);
		log.setHandleType(handleType);
		log.setAboutClass(aboutClass.getName());
		log.setNote(note);
		if (CommonUtil.isNotEmpty(userLoginInfo)) {
			log.setUserInfo(userLoginInfo.getUserInfo());
		}
		return dao.save(log);
	}

}
